package com.mission.datasave

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.widget.ArrayAdapter
import android.widget.Toast
import com.mission.datasave.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

    private lateinit var mBinding: ActivityMainBinding
    private val strArrays = arrayOf("FileActivity", "SharePreferenceActivity", "SQLiteActivity")

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mBinding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(mBinding.root)

        mBinding.listView.adapter =
            ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, strArrays)
        mBinding.listView.setOnItemClickListener { parent, view, position, id ->
            when (position) {
                0 -> FileActivity.start(this@MainActivity)
                1 -> SharedPreferencesActivity.start(this@MainActivity)
                2 -> Toast.makeText(this@MainActivity, "2", Toast.LENGTH_SHORT).show()
            }
        }
    }
}